import { mapGetters, mapActions } from "vuex";
import TransferDom from "vux/src/directives/transfer-dom/index.js";

import _ from "lodash";
import { websocketsend } from "@/assets/js/websocket";
import { timeFormat } from "@/assets/js/dom";

import template from "./chatRoomTemplate";
const { render, staticRenderFns } = template;

export default {
  render,
  staticRenderFns,
  props: ["allMessage", "userData", "showLotList"],
  components: {},
  directives: {
    TransferDom,
  },
  mounted() {
    var chatRoom = document.getElementById("chatRoom");
    var roomTop = document.getElementById("roomTop");
    var chatIptBox = document.getElementById("chatIptBox");
    var lotRecord = document.getElementById("lotRecord");
    var zjpcPanel = document.getElementById("zjpcPanel");
    var flListPanel = document.getElementById("flListPanel");
    var followItem = document.getElementById("followItem");

    this.$nextTick(() => {
      chatRoom.style.top = roomTop.offsetHeight + "px";
      lotRecord.style.top = roomTop.offsetHeight + "px";
      zjpcPanel.style.top = roomTop.offsetHeight + 50 + "px";
      flListPanel.style.top = roomTop.offsetHeight + "px";
      flListPanel.style.height =
        window.innerHeight - roomTop.offsetHeight + "px";
      followItem.style.top = roomTop.offsetHeight + "px";
      followItem.style.height =
        window.innerHeight - roomTop.offsetHeight + "px";
      chatRoom.style.bottom = chatIptBox.offsetHeight + "px";
    });
    if (this.accountData && this.accountData.is_tourist === 1) {
      this.isTourist = true;
    }
    this.bqtzScroll();
    if (
      this.$route.query.lottery_type == 7 ||
      this.$route.query.lottery_type == 8 ||
      this.$route.query.lottery_type == 24
    ) {
      this.isLhc = true;
    }
  },
  created() {},
  data() {
    return {
      isLhc: false,
      msgList: [], //需要展示的msg
      showFollowDlg: false, //跟投modal
      followOddsData: {
        money: [],
        way: [],
      }, //追号数据
      scrollToEndFlag: true,
      showRightList: true,
      showGoDown: false,
      showFixedRight: true,
      myLotList: [], //投注记录
      hasBackOdds: [], //已撤订单
      totalZu: 0,
      playAgainFlag: false,

      setZhFlag: false,
      zhTableData: [],
      zhDataList: [],
      zbycData: {},
      pcMessage: [],
      followStatus: 1,
      followList: [],
      showFlList: false,
      isTourist: false,
      showFollowItem: false,
      followItemData: { user: "", orderList: [] },
      token: localStorage.getItem("token"),
      inBottom: false,
      showLhcGtDlg: false,
      lhcGtData: {},
      page: 0,
      followItemInfo: {},
      issue: "",
      followObj: {},
    };
  },
  computed: {
    ...mapGetters(["roomData", "accountData", "serTime", "newRstData"]),
  },
  methods: {
    closeFollow: function () {
      this.showFlList = false;
      this.showFollowItem = false;
      var obj = this.roomData;
      obj.showAskRoad = false;
      this.$store.commit("setRoomData", obj);
    },
    followItem: function (id) {
      let vm = this;
      let params = {};
      params.token = localStorage.getItem("token");
      params.user_id = id;
      params.room_id = this.$route.query.id;
      vm.$http
        .post(vm.urlRequest + "?m=api&c=userfollow&a=followUserBetInfo", params)
        .then((res) => {
          if (res.status == 0) {
            this.followItemData = res.data;
            this.followItemInfo = res.userData;
            this.followItemInfo.id = id;
            this.showFollowItem = true;
          } else {
            this.$vux.toast.show({
              text: "数据请求超时",
            });
          }
        });
    },
    qxFollow: function (id) {
      this.$http
        .post(this.urlRequest + "?m=api&c=user&a=cancelFollowUser", {
          user_id: id,
        })
        .then((res) => {
          if (res.ret_msg && res.ret_msg != "") {
            this.$vux.toast.show({
              text: res.ret_msg,
            });
          }
          if (res.status == 0) {
            this.getFollowList();
            this.showFollowItem = false;
            this.showFlList = true;
          }
        });
    },
    bqtzScroll: function () {
      //本期投注下拉加载
      var that = this;
      var scrollDiv = document.getElementById("lotRecordUl");
      scrollDiv.onscroll = function () {
        if (
          scrollDiv.scrollTop + scrollDiv.clientHeight ==
          scrollDiv.scrollHeight
        ) {
          that.inBottom = true;
        } else {
          that.inBottom = false;
        }
      };
    },
    setPhFollow: function (item) {
      if (this.followObj[item.user_id]) {
        return false;
      }
      var uid = item.user_id;
      this.$http
        .post(this.urlRequest + "?m=api&c=user&a=addFollowUser", {
          user_id: uid,
        })
        .then((res) => {
          if (res.ret_msg && res.ret_msg != "") {
            this.$vux.toast.show({
              text: res.ret_msg,
            });
          }
          if (res.status == 0) {
            this.followObj[item.user_id] = true;
            console.log("followObj", this.followObj);
          }
          this.$vux.loading.hide();
          return;
        });
    },
    setFollow: function (uid) {
      this.$vux.loading.show();
      if (this.followStatus == 0) {
        this.$http
          .post(this.urlRequest + "?m=api&c=user&a=cancelFollowUser", {
            user_id: uid,
          })
          .then((res) => {
            if (res.ret_msg && res.ret_msg != "") {
              this.$vux.toast.show({
                text: res.ret_msg,
              });
            }
            if (res.status == 0) {
              this.followStatus = 1;
            }
            this.$vux.loading.hide();
            return;
          });
      } else {
        this.$http
          .post(this.urlRequest + "?m=api&c=user&a=addFollowUser", {
            user_id: this.followOddsData.uid,
          })
          .then((res) => {
            if (res.ret_msg != "") {
              this.$vux.toast.show({
                text: res.ret_msg,
              });
            }
            if (res.status == 0) {
              this.followStatus = 0;
            }
            this.$vux.loading.hide();
            return;
          });
      }
    },
    getFollowList: function () {
      this.$vux.loading.show();
      let params = {};
      params.token = localStorage.getItem("token");
      params.page = this.page;
      this.$http
        .post(this.urlRequest + "?m=api&c=userfollow&a=followUserList", params)
        .then((res) => {
          this.followList = res.data;
          this.$vux.loading.hide();
          this.showFlList = true;
        });
    },
    goBottom: function () {
      setTimeout(() => {
        this.$refs.scroll.scrollTo(
          0,
          -this.$refs.scroll.$el.scrollHeight +
            this.$refs.scroll.$el.clientHeight,
          500
        );
      }, 20);
    },
    setZhOddsDlg: function (flag) {
      //打开追号注单面板
      if (flag) {
        this.$vux.loading.show();
        this.$http
          .post(this.urlRequest + "?m=api&c=order&a=getZhuiHaoInfo", {
            room_id: this.$route.query.id,
          })
          .then((res) => {
            this.$vux.loading.hide();
            if (res.list.length > 0) {
              this.zhDataList = res.list;
              this.setZhFlag = true;
              this.zhOddsDlg = flag;
            } else {
              this.$vux.toast.show({
                text: res.msg,
              });
            }
          })
          .catch((error) => {
            this.$vux.loading.hide();
            this.$vux.toast.show({
              text: "数据请求超时",
            });
          });
      }
    },
    sendBacOnekOdds: function (order_no) {
      var that = this;
      this.$vux.confirm.show({
        content: "您确定要撤单吗？",
        onConfirm: () => {
          const agentData = {
            commandid: "3016",
            uid: that.userData.id,
            order_no: order_no,
          };
          websocketsend(agentData);
          this.$vux.loading.show();
        },
      });
    },
    setMiPai: function () {
      if (_.isEmpty(this.allMessage)) {
        return;
      }
      var obj = this.roomData;
      obj.showMiPai = !obj.showMiPai;
      this.$store.commit("setRoomData", obj);
    },
    sendPlayAgainOdds: function () {
      if (this.roomData.stopBet) {
        this.$vux.alert.show({ content: "当前不在投注时间，不能投注" });
        return;
      }
      const agentData = {
        token: this.token,
        commandid: "3006",
        nickname: this.userData.nickname,
        way: [this.zbycData.way],
        money: [this.zbycData.money],
        avatar: this.userData.avatar,
      };
      var uniNo = new Date().getTime() + Math.floor(Math.random() * 900) + 100;
      var params = {
        user_id: this.userData.id,
        lottery_type: this.$route.query.lottery_type,
        room_id: this.$route.query.id,
        nickname: this.userData.nickname,
        money: JSON.stringify([this.zbycData.money]),
        issue: this.roomData.issue,
        way: JSON.stringify([this.zbycData.way]),
        single_money: JSON.stringify([this.zbycData.money]),
        ext_a: 1,
        serTime: this.serTime,
        uniNo: uniNo,
      };
      let lotRstData = {
        isHttp: true,
        isLoading: true,
        avatar: this.userData.avatar,
        commandid: 30007,
        issue: this.roomData.issue,
        money: [this.zbycData.money],
        nickname: this.userData.nickname,
        time: timeFormat(new Date().getTime()),
        total_money: this.zbycData.money,
        total_zushu: 1,
        single_money: [this.zbycData.money],
        uid: this.userData.id,
        uniNo: uniNo,
        sort: this.userData.honor.sort,
        serTime: this.serTime,
        order_no: "",
        way: [this.zbycData.way],
        loadingFailed: false,
        failedText: "网络错误，请重试",
      };
      this.$store.commit("setLotRstData", lotRstData);
      this.$http
        .post(this.urlRequest + "?m=api&c=workerman&a=http_betting", params)
        .then(
          (result) => {
            if (result.commandid != 3007) {
              var failedObj = JSON.parse(JSON.stringify(lotRstData));
              failedObj.loadingFailed = true;
              failedObj.failedText = result.content;
              this.$store.commit("setNewRstData", failedObj);
              return;
            }
            var accountData = this.accountData;
            accountData.money_usable = result.current_money;
            this.$store.commit("setAccountData", accountData);
            this.$store.commit("setNewRstData", result);
          },
          (err) => {
            lotRstData.loadingFailed = true;
            this.$store.commit("setNewRstData", lotRstData);
          }
        );

      this.playAgainFlag = false;
    },
    qxOneLot: function (index) {
      if (this.roomData.stopBet) {
        this.$vux.alert.show({
          content: "本期已封盘，禁止撤单",
        });
        return;
      }
      var that = this;
      var order_no = this.myLotList[index].order_no;
      this.$vux.confirm.show({
        content: "取消投注后将返还所有下注金额？",
        onConfirm: function () {
          const agentData = {
            commandid: "3016",
            uid: that.userData.id,
            order_no: order_no,
          };
          websocketsend(agentData);
        },
      });
    },
    setLotList: function () {
      if (this.showLotList) {
        this.$emit("setLotList", false);
      } else {
        this.$emit("setLotList", true);
      }
    },
    showAllBackStyle: function (orderArr) {
      //一组撤单style
      if (!_.isArray(orderArr)) {
        orderArr = [orderArr];
      }
      var count = 0;
      for (var j = 0; j < orderArr.length; j++) {
        for (var i = 0; i < this.hasBackOdds.length; i++) {
          if (orderArr[j] == this.hasBackOdds[i]) {
            count++;
          }
        }
      }
      if (count == orderArr.length) {
        return true;
      } else {
        return false;
      }
    },
    showBackStyle: function (order_no) {
      //单注撤单style
      var flag = false;
      if (this.hasBackOdds.length > 0) {
        for (var i = 0; i < this.hasBackOdds.length; i++) {
          if (this.hasBackOdds[i] == order_no) {
            flag = true;
            break;
          }
        }
        return flag;
      }
    },
    cancelAllOdds: function () {
      if (this.roomData.stopBet) {
        this.$vux.alert.show({
          content: "本期已封盘，禁止撤单",
        });
        return;
      }
      var that = this;
      this.$vux.confirm.show({
        content: "取消投注后将返还所有下注金额？",
        onConfirm: function () {
          const agentData = {
            commandid: "3009",
            lottery_type: that.$route.query.lottery_type,
            roomid: that.$route.query.id,
            uid: that.userData.id,
          };
          websocketsend(agentData);
        },
      });
    },
    myFollowOdds: function (item) {
      if (this.roomData.stopBet) {
        this.$vux.alert.show({ content: "当前不在投注时间，不能投注" });
        return;
      }
      item.money = parseInt(item.money);
      const agentData = {
        token: this.token,
        commandid: "3006",
        nickname: this.userData.nickname,
        way: [item.way],
        money: [item.money],
        ext_a: 1,
        single_money: [item.single_money],
        avatar: this.userData.avatar,
      };
      var uniNo = new Date().getTime() + Math.floor(Math.random() * 900) + 100;
      var params = {
        user_id: this.userData.id,
        lottery_type: this.$route.query.lottery_type,
        room_id: this.$route.query.id,
        nickname: this.userData.nickname,
        money: JSON.stringify([item.money]),
        issue: this.roomData.issue,
        way: JSON.stringify([item.way]),
        single_money: JSON.stringify([item.single_money]),
        ext_a: 1,
        serTime: this.serTime,
        uniNo: uniNo,
      };
      let lotRstData = {
        isHttp: true,
        isLoading: true,
        avatar: this.userData.avatar,
        commandid: 30007,
        issue: this.roomData.issue,
        money: [item.money],
        nickname: this.userData.nickname,
        time: timeFormat(new Date().getTime()),
        total_money: item.money,
        total_zushu: 1,
        single_money: [item.single_money],
        uid: this.userData.id,
        uniNo: uniNo,
        sort: this.userData.honor.sort,
        serTime: this.serTime,
        order_no: "",
        way: [item.way],
        loadingFailed: false,
        failedText: "网络错误，请重试",
      };
      this.$store.commit("setLotRstData", lotRstData);
      this.$http
        .post(this.urlRequest + "?m=api&c=workerman&a=http_betting", params)
        .then(
          (result) => {
            if (result.commandid != 3007) {
              var failedObj = JSON.parse(JSON.stringify(lotRstData));
              failedObj.loadingFailed = true;
              failedObj.failedText = result.content;
              this.$store.commit("setNewRstData", failedObj);
              return;
            }
            var accountData = this.accountData;
            accountData.money_usable = result.current_money;
            this.$store.commit("setAccountData", accountData);
            this.$store.commit("setNewRstData", result);
          },
          (err) => {
            lotRstData.loadingFailed = true;
            this.$store.commit("setNewRstData", lotRstData);
          }
        );

      this.showFlList = false;
      this.showFollowItem = false;
    },
    followOdds: function (item) {
      if (item.isLoading) {
        return;
      }
      if (this.roomData.stopBet) {
        this.$vux.toast.show({ text: "已封盘，不能跟投" });
        return;
      }
      if (item.loadingFailed) {
        this.showFailedText(item.failedText);
      }
      var data = JSON.stringify(item);
      data = JSON.parse(data);
      var newArr = [];
      if (_.isArray(data.way)) {
        for (var i = 0; i < data.way.length; i++) {
          newArr.push({
            issue: data.issue,
            way: data.way[i],
            money: data.money[i],
          });
        }
      } else {
        newArr.push({
          issue: data.issue,
          way: data.way,
          money: data.money,
        });
      }
      this.followOddsData.issue = data.issue;
      this.followOddsData.avatar = data.avatar;
      this.followOddsData.sort = data.sort;
      this.followOddsData.uid = data.uid;
      this.followOddsData.nickname =
        data.uid == this.uid ? this.userName : data.nickname;
      this.followOddsData.totalMoney = data.total_money || data.money;
      this.followOddsData.totalZhu = data.total_zushu || data.zushu;
      this.followOddsData.way = _.isArray(data.way) ? data.way : [data.way];
      this.followOddsData.money = _.isArray(data.money)
        ? data.money
        : [data.money];
      if (
        this.$route.query.lottery_type == 7 ||
        this.$route.query.lottery_type == 8 ||
        this.$route.query.lottery_type == 24
      ) {
        this.followOddsData.single_money = _.isArray(data.single_money)
          ? data.single_money
          : [data.single_money];
      }
      this.$http
        .post(this.urlRequest + "?m=api&c=user&a=checkFollowUser", {
          user_id: this.followOddsData.uid,
        })
        .then((res) => {
          this.followStatus = res.code;
        });
      this.showFollowDlg = true;
    },
    showLhcGt: function (index) {
      this.showFollowDlg = false;
      this.lhcGtData = {
        way: this.followOddsData.way[index],
        totalMoney: this.followOddsData.money[index],
        totalZhu:
          this.followOddsData.money[index] /
          this.followOddsData.single_money[index],
        single_money: this.followOddsData.single_money[index],
        index: index,
      };
      this.showLhcGtDlg = true;
    },
    closeGtDlg: function () {
      this.showLhcGtDlg = false;
      this.showFollowDlg = true;
    },
    sendLhcGt: function () {
      if (this.lhcGtData.totalMoney <= 0) {
        this.$vux.toast.show({ text: "金额有误" });
        return;
      }
      this.followOddsData.single_money[
        this.lhcGtData.index
      ] = this.lhcGtData.single_money;
      this.followOddsData.money[
        this.lhcGtData.index
      ] = this.lhcGtData.totalMoney;
      var count = 0;
      for (var i = 0; i < this.followOddsData.money.length; i++) {
        count += this.followOddsData.money[i];
      }
      this.followOddsData.totalMoney = count;
      this.closeGtDlg();
    },
    sendFollowOdds: function () {
      if (this.roomData.stopBet) {
        this.$vux.alert.show({ content: "当前不在投注时间，不能投注" });
        return;
      }
      const agentData = {
        token: this.token,
        commandid: "3006",
        nickname: this.userData.nickname,
        way: this.followOddsData.way,
        money: this.followOddsData.money,
        ext_a: 1,
        single_money: this.followOddsData.single_money,
        avatar: this.userData.avatar,
      };
      var uniNo = new Date().getTime() + Math.floor(Math.random() * 900) + 100;
      var params = {
        user_id: this.userData.id,
        lottery_type: this.$route.query.lottery_type,
        room_id: this.$route.query.id,
        nickname: this.userData.nickname,
        money: JSON.stringify(this.followOddsData.money),
        issue: this.roomData.issue,
        way: JSON.stringify(this.followOddsData.way),
        single_money: JSON.stringify(this.followOddsData.single_money),
        ext_a: 1,
        serTime: this.serTime,
        uniNo: uniNo,
      };
      let lotRstData = {
        isHttp: true,
        isLoading: true,
        avatar: this.userData.avatar,
        commandid: 30007,
        issue: this.roomData.issue,
        money: this.followOddsData.money,
        nickname: this.userData.nickname,
        time: timeFormat(new Date().getTime()),
        total_money: this.followOddsData.totalMoney,
        total_zushu: this.followOddsData.totalZhu,
        single_money: this.followOddsData.single_money,
        uid: this.userData.id,
        uniNo: uniNo,
        sort: this.userData.honor.sort,
        serTime: this.serTime,
        order_no: "",
        way: this.followOddsData.way,
        loadingFailed: false,
        failedText: "网络错误，请重试",
      };
      this.$store.commit("setLotRstData", lotRstData);
      this.$http
        .post(this.urlRequest + "?m=api&c=workerman&a=http_betting", params)
        .then(
          (result) => {
            if (result.commandid != 3007) {
              var failedObj = JSON.parse(JSON.stringify(lotRstData));
              failedObj.loadingFailed = true;
              failedObj.failedText = result.content;
              this.$store.commit("setNewRstData", failedObj);
              return;
            }
            var accountData = this.accountData;
            accountData.money_usable = result.current_money;
            this.$store.commit("setAccountData", accountData);
            this.$store.commit("setNewRstData", result);
          },
          (err) => {
            lotRstData.loadingFailed = true;
            this.$store.commit("setNewRstData", lotRstData);
          }
        );

      this.showFollowDlg = false;
    },
    showAskRoad: function () {
      var obj = this.roomData;
      obj.showAskRoad = true;
      this.$store.commit("setRoomData", obj);
    },
    setEndFlagFun: function (res) {
      this.scrollToEndFlag = res;
      this.showGoDown = !res;
    },
    showFailedText: function (text) {
      this.$vux.alert.show({
        content: text,
      });
    },
  },
  watch: {
    accountData: function (newVal) {
      if (!_.isEmpty(newVal)) {
        if (newVal.is_tourist && newVal.is_tourist === 1) {
          this.isTourist = true;
        }
      }
    },
    roomData: {
      handler(newVal, oldVal) {
        this.issue = newVal.issue;
      },
      deep: true,
    },
    issue: {
      handler(newVal, oldVal) {
        if (newVal != oldVal) {
          this.myLotList = [];
          this.totalZu = 0;
          this.hasBackOdds = [];
          this.playAgainFlag = false;
        }
      },
      deep: true,
    },
    serTime: function (newVal) {
      newVal = JSON.parse(JSON.stringify(newVal));
      for (var i = 0; i < this.msgList.length; i++) {
        if (this.msgList[i].commandid == 30007 && this.msgList[i].isLoading) {
          if (newVal - this.msgList[i].serTime > 10) {
            this.msgList[i].failedText = "投注超时，请重新下注";
            this.msgList[i].loadingFailed = true;
            break;
          }
        }
      }
    },
    newRstData: function (newVal) {
      newVal = JSON.parse(JSON.stringify(newVal));
      for (var i = 0; i < this.msgList.length; i++) {
        if (this.msgList[i].uniNo == newVal.uniNo) {
          if (newVal.loadingFailed) {
            this.msgList[i].failedText = newVal.failedText;
            this.msgList[i].loadingFailed = true;
            return false;
          }
          this.msgList[i].isLoading = false;
          this.msgList[i].order_no = newVal.order_no;
          this.msgList[i].total_zushu = newVal.total_zushu;

          var newArr = [];
          this.totalZu = parseInt(this.totalZu) + newVal.total_zushu;
          if (_.isArray(newVal.way)) {
            for (var j = 0; j < newVal.way.length; j++) {
              newArr.push({
                type: newVal.way[j],
                money: newVal.money[j],
                order_no: newVal.order_no[j],
              });
            }
          } else {
            newArr.push({
              type: newVal.way[0],
              money: newVal.money[0],
              order_no: "123456",
            });
          }
          this.myLotList = this.myLotList.concat(newArr);
          console.log(this.msgList[i], "this.msgList[i]");
          break;
        }
      }
    },
    allMessage: {
      handler(newVal, oldVal) {
        newVal = JSON.parse(JSON.stringify(newVal));
        if (newVal.commandid != 3023) {
          this.msgList.push(newVal);
          if (newVal.commandid == 30007) {
            console.log(newVal, "第一次");
          }
        } else {
          if (_.isEmpty(newVal.data)) {
            return;
          }
          if (this.pcMessage.length < 1) {
            this.pcMessage.push(newVal.data);
          }
        }
        if (
          (newVal.commandid == 30007 || newVal.commandid == 3004) &&
          this.userData.id == newVal.uid
        ) {
          this.goBottom();
        }
        if (newVal.commandid == 3001) {
        }
        if (newVal.commandid == 3018) {
          let newArr = [];
          this.totalZu = newVal.totalZu || 0;
          if (!_.isEmpty(newVal.data)) {
            for (var j = 0; j < newVal.data.length; j++) {
              if (
                newVal.data[j].uid == this.userData.id &&
                newVal.data[j].issue == this.roomData.issue
              ) {
                newArr.push({
                  type: newVal.data[j].way,
                  money: newVal.data[j].money,
                  order_no: newVal.data[j].order_no,
                });
              }
            }
            this.myLotList = this.myLotList.concat(newArr);
          } else {
            if (this.inBottom) {
              this.$vux.toast.show({ text: "没有更多了" });
            }
          }
        }
        if (newVal.commandid == 3015) {
          if (_.isEmpty(newVal.order_no)) {
            this.hasBackOdds = this.hasBackOdds.concat(newVal.order_list);
            this.myLotList = [];
            this.totalZu = 0;
          } else {
            for (var i = 0; i < this.myLotList.length; i++) {
              if (this.myLotList[i].order_no == newVal.order_no) {
                this.myLotList.splice(i, 1);
                this.totalZu--;
                break;
              }
            }
            this.hasBackOdds.push(newVal.order_no);
          }
        }
        if (newVal.commandid == 3011) {
        }
        if (newVal.commandid == 3019) {
          this.$vux.toast.show({ text: "追号成功" });
          this.goBottom();
        }
        if (newVal.commandid == 3022) {
          this.setZhFlag = false;
          this.$vux.loading.hide();
        }
        if (newVal.commandid == 3025) {
          this.zbycData = {
            way: newVal.way,
            money: parseInt(newVal.money),
          };
        }
      },
      deep: true,
    },
    myLotList: function (newVal) {
      console.log(newVal, "myLotList");
      if (newVal.length < 1) {
        this.$emit("setLotList", false);
      }
    },
    pcMessage: {
      handler(newVal, oldVal) {
        if (newVal.length == 1) {
          var that = this;
          console.log(this.pcMessage.length);
          setTimeout(function () {
            that.pcMessage = [];
          }, 10000);
        }
      },
      deep: true,
    },
    followOddsData: {
      handler(newVal, oldVal) {
        var toltalMoney = 0;
        for (var i = 0; i < newVal.way.length; i++) {
          newVal.money[i] =
            parseFloat(newVal.money[i]) > 0 ? parseFloat(newVal.money[i]) : 0;
          toltalMoney += newVal.money[i];
        }
        newVal.totalMoney = toltalMoney;
      },
      deep: true,
    },
    scrollToEndFlag: function (newVal) {
      console.log(newVal);
    },
    inBottom: function (newVal) {
      if (newVal) {
        const agentData = {
          commandid: "3017",
          uid: this.userData.id,
          roomid: this.$route.query.id,
          lottery_type: this.$route.query.lottery_type,
          offSet: this.myLotList.length,
        };
        websocketsend(agentData);
      }
    },
    lhcGtData: {
      handler(newVal) {
        if (newVal) {
          newVal.totalMoney = newVal.single_money * newVal.totalZhu;
        }
      },
      deep: true,
    },
  },
};

// WEBPACK FOOTER //
// ./src/components/room/chatRoom/chatRoom.vue
